package com.jack.leetcode.每日一题;

public class 新21点 {

    public static void main(String[] args) {
        System.out.println(new21Game(21,17,10));
        System.out.println(new21Game(10,1,10));
        System.out.println(new21Game(6,1,10));
    }

    public static double new21Game(int N, int K, int W) {
        double[] dp = new double[K + W];
        double s = 0;
        for (int i = K; i < K + W; i++) {
            dp[i] = i <= N ? 1 : 0;
            s+=dp[i];
        }
        for(int i = K-1;i>=0;i--){
            dp[i] = s/W;
            s = s-dp[i+W]+dp[i];
        }
        return dp[0];
    }
}
